package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.catalina.ssi.SSICommand;

import com.zr.service.StuentService;

import net.sf.json.JSONObject;

public class SelectCnameController extends HttpServlet {
	StuentService ss=new StuentService();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String t=req.getParameter("tid");
		String cname=req.getParameter("cname");
		
		String page=req.getParameter("page");
		String row=req.getParameter("rows");
		System.out.println(t);
		System.out.println(cname);
		System.out.println(page);
		System.out.println(row);
		int tid=Integer.parseInt(t);
		int rows=Integer.parseInt(row);
		int start=(Integer.parseInt(page)-1)*rows;
		resp.setCharacterEncoding("utf8");
		JSONObject jso=ss.selectCname(start, rows, tid, cname);
		PrintWriter pw=resp.getWriter();
		pw.write(jso.toString());
	}
}
